<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HTML>
<HEAD>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/top.css" />
<title>考勤报表</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>/css/popcalendar.css" />
<script src="<%=basePath%>/js/popcalendar.js"></script>
<script src="<%=basePath%>/js/function.js"></script>
<LINK href="<%=basePath%>/css/main.css" type="text/css" rel="stylesheet" />

</HEAD>
<script type="text/javascript">
function method2(tableid) //读取表格中每个单元到EXCEL中 
{  

    var curTbl = document.getElementById(tableid); 
    
      try { 
            var oXL = new ActiveXObject("Excel.Application"); 
      } 
      catch(e) 
      { 
        alert( "您必须安装Excel2000或以上，同时浏览器须使用“ActiveX 控件”，您的浏览器须允许执行控件。请选择Internet设置--安全选项--本地Intranet--改区域的安全级别设置为低，才能导出到Excel！"); 
        
        window.location.reload(); 
        return ""; 
      } 
    
    //创建AX对象excel 
    var oWB = oXL.Workbooks.Add(); 
    //获取workbook对象 
    var oSheet = oWB.ActiveSheet; 
    //激活当前sheet 
    var Lenr = curTbl.rows.length; 
    //取得表格行数 
    for (i = 0; i < Lenr; i++) 
    { 
        var Lenc = curTbl.rows(i).cells.length; 
        

        //<!--设置显示字符而不是数字--> 
          
        oSheet.Columns(6).NumberFormatLocal="@" 
        oSheet.Columns(5).NumberFormatLocal="@"; 
        oSheet.Columns(8).NumberFormatLocal="@"; 
        //取得每行的列数 
        for (j = 0; j < Lenc; j++) 
        { 
            oSheet.Cells(i + 1, j + 1).value = curTbl.rows(i).cells(j).innerText; 
            //赋值 
        } 
    } 
    oXL.Selection.HorizontalAlignment = -4108;        //'xlHAlignCenter  横向居中 
    //oXL.Range("a1:b1:c1:d1:f1:g1:h1:i1:j1:k1").MergeCells = true;//合并 
    //oXL.Range("a1:b1").select;//选中 
    //oXL.Selection.VerticalAlignment = -4108;          //'xlVAlignCenter  竖向居中 
    oSheet.Columns.AutoFit; //自动适应大小 
    //设置excel可见属性 
    oXL.Visible = true; 
    oXL.UserControl = true;  //excel交由用户控制 

} 




 
      function saveToExcel() 
   { 
     var oXL = new ActiveXObject("Excel.Application"); 
     var oWB = oXL.Workbooks.Add(); 
     var oSheet = oWB.ActiveSheet; 
     var sel=document.body.createTextRange(); 
     sel.moveToElementText(tableId); 
     sel.select(); 
     sel.execCommand("Copy"); 
     oSheet.Paste(); 
     oXL.Visible = true; 
   } 




</script>
<body topmargin="5">

<form name="Form1" method="post" action="leave.aspx" id="Form1">
<div><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
	value= /></div>

<table border="0" width="100%" cellspacing="0" cellpadding="3"
	class="small">
	<tr>
		<td class="Big"><img
			src="<%=basePath%>/img/office/attendance.gif" WIDTH="18" HEIGHT="18"
			align="absmiddle"><span class="big3"> 考勤报表</span><br />
		</td>
	</tr>
</table>

<br />

<div align="center"><br />
<table border="0" cellspacing="1" width="95%" class="small"
	bgcolor="#000000" cellpadding="3">

</table>
</div>

<br />

<table id="tableid" border="0" cellspacing="1" width="95%" class="small"
	bgcolor="#000000" cellpadding="3" align="center">
	<TR class="TableHeader">
		<td nowrap align="center">序号</td>
		<td nowrap align="center">姓名</td>
		<td nowrap align="center">出勤总天数</td>
		<td nowrap align="center">结束时间</td>
		<td nowrap align="center">假类</td>
		<td nowrap align="center">天数</td>
		<td nowrap align="center">缺勤迟到</td>
		<td nowrap align="center">出差天数</td>
		<td nowrap align="center">加班天数</td>
		<td nowrap align="center">备注</td>
	</TR>

	<tr class="TableData">
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
		<td nowrap align="center">1</td>
	</tr>



</table>

<table border="0" cellspacing="1" width="95%" class="small"
	bgcolor="#000000" cellpadding="3" align="center">
	<tr>
		<td align="center" class="TableData" nowrap><input
			class=BigButton type="button" id="mybutton"
			onclick="method2('tableid')" value="导出到Execl" />
		&nbsp;&nbsp;&nbsp;&nbsp;<input class=BigButton type="button"
			value="返回" onclick="" /></td>

	</tr>
</table>


</form>

</body>
</html>
